<%@ page language="java" import="java.util.*, java.io.*, 
	org.apache.ibatis.io.*,
	org.apache.ibatis.session.*, 
	static com.expmanage.actions.utils.DatabaseConfigure.*,
	com.expmanage.models.*" contentType="text/html;charset=gb2312" 
	pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    <title>实验评分与选课记录确认情况</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
</head>

  <body>
  		<%
		if (session.getAttribute("user") == null
			|| !session.getAttribute("role").equals("student")) {
		%>
		<script language="javascript">
			alert("需要登录");
			window.open("index.jsp", "_self");
		</script>
		<%
			}
		%>
  
  	<%!
  	void loadCourseChoose(JspWriter out, Integer sid){
		if(sqlSessionFactory!=null){
			SqlSession sqlsession = sqlSessionFactory.openSession();
       		try {
           		ChooseCourseInfoMapper mapper = 
           			sqlsession.getMapper(ChooseCourseInfoMapper.class);
           		List<ChooseCourseInfo> coursesInfo = 
           			mapper.selectChooseCourseInfoByStuID(sid);
           		for (ChooseCourseInfo info : coursesInfo) {
               		out.print("<tr><td>"+ info.getCname() + "</td>"
               			+ "<td>"+ info.getScore() + "</td>" 
               			+ "<td>"+ info.isConfirm() + "</td>" 
               			+ "<td>"+ info.getNotation()+ "</td>" 
               			+ "</tr>");
            	}
        	} catch(Throwable e){
        		e.printStackTrace();
       		} finally {
           		sqlsession.close();
       		}
       	}else{
       		//输出错误
      	}
  	}
  	%>
    	<table>
    	<tr><td>评分与选课记录确认情况：</td></tr>
    	</table>
    	<table border=1>
    	<tr>
    		<td>课程名</td><td>评分</td><td>选课记录是否确认</td><td>评语</td>
    	</tr>
    	<%
		if (session.getAttribute("user") != null
			&& session.getAttribute("role").equals("student")) {
			loadCourseChoose(out, (Integer)session.getAttribute("sid"));
		}
		%>
		</table>
  </body>
</html>
